﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Net;
using System.Threading;

namespace Innovox.NetTools
{
    class HttpWebRequestBuilder
    {
        const int DefaultTimeout = 20000;
        const int RWTimeout = 20000;

        static public HttpWebRequest CreateRequest(string url)
        {
            HttpWebRequest httpGetRequest = (HttpWebRequest)WebRequest.Create(url);
            Initialize(httpGetRequest);
            return httpGetRequest;
        }
        
        static void Initialize(HttpWebRequest request)
        {
            SetDefaultTimeouts(request);
            SetCommonProperties(request);
        }

        static private void SetDefaultTimeouts(HttpWebRequest request)
        {
            request.Timeout = DefaultTimeout;
            request.ReadWriteTimeout = RWTimeout;
        }

        static private void SetCommonProperties(HttpWebRequest request)
        {
            request.KeepAlive = false;
            request.AuthenticationLevel = System.Net.Security.AuthenticationLevel.None;
            request.ContentType = "text/xml";
        }
    }
}
